package com.alibaba.ai;

import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class McpServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(McpServerApplication.class, args);
    }
    //工具注册：weatherTools Bean将 OpenMeteoService 注册为MCP工具
    @Bean
    public ToolCallbackProvider weatherTools(OpenMeteoService openMeteoService) {
        //使用 MethodToolCallbackProvider.builder() 创建构建器
        //通过 toolObjects(openMeteoService) 将 OpenMeteoService 对象注册为可调用的工具
        //调用 build() 构建最终的 ToolCallbackProvider 实例
        return MethodToolCallbackProvider.builder().toolObjects(openMeteoService).build();
    }

}
